<?php

session_start();

$customer_id = $_SESSION['userid'];

$product_row_id = "{product_id}";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="SHORTCUT ICON" href="images/url_logo.png">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Buy secondhand horse saddles online with our large range of horse saddles for most disciplines including General Purpose | Dressage | Eventing | Working | Hunter and VSD. Buy or sell used horse saddles online.">

<title>24-7 Saddles | Second hand horse saddle</title>

<link href="../css/header.css" rel="stylesheet" type="text/css">
<link href="../css/navigation.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="../js/product_details_payment_calcs2.js"></script>

<style type="text/css">
body {
	background-image: url(../images/wood2.jpg);
	background-repeat: repeat-x;
	margin: 0px;
	background-position: left top;
	background-attachment: fixed;
	background-color: #000000;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
}
</style>
<link href="../css/product_details.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>
</head>

<body>

<div id="page_container">

<?php include "../connect.php" ?>

<?php include "header.php" ?>

<?php include "navigation.php" ?>

<div id="product_container">

<?

//create a list of products that are being watched by the customer
//if the customer is logged in then create array
if($customer_id > 0) 

{

	$alert_list = array();
	$query = "SELECT * FROM customer_alerts WHERE customer_id = $customer_id";
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result))
	
		{
    		array_push($alert_list,$row['product_id']);
    	}

}

//get saddle status

$product_query = "SELECT * FROM saddles WHERE id = $product_row_id";
$product_result = mysql_query($product_query);
while($product_row = mysql_fetch_array($product_result))

{
	
$product_id 			= $product_row['product_id'];
$product_type 			= $product_row['product_type'];
$product_catagory 		= $product_row['product_catagory'];
$product_sub_catagory	= $product_row['product_sub_catagory'];
$product_name 			= $product_row['product_name'];
$product_status 		= $product_row['product_status'];
$product_cost 			= $product_row['product_cost'];
$product_description	= $product_row['product_description'];
$product_make 			= $product_row['product_make'];
$product_colour 		= $product_row['product_colour'];
$product_size			= $product_row['product_size'];
$product_offer 			= $product_row['product_offer'];

}



if($product_status == "On-trial")
{

	//guest
	if($customer_id == 0) //User not logged in
	{

	echo  '<div id="trial_alert">
		   <p><b>On trial</b>Register your email and we will alert you when this saddle becomes available.</p>
		   <form action="http://www.24-7saddles.com/add_alertlist.php" method="post" name="trial_alert">
		   <input name="product_id" type="hidden" value="'.$product_id.'" />
		   <input id="alert_email" name="customer_email" type="text" placeholder="Enter your email address" /> 
		   <input id="alert_button" name="alert_button" type="submit" value="Alert" />
		   <a>Terms & conditions</a> 
	       </form>
	       </div>
	       <!--trial_alert-->'
	;}

	//member
	if($customer_id > 0) //User is logged in
	{
		//Has alert set up already
		if((in_array($product_id, $alert_list)) ) //
		{
		
		echo  '<div id="trial_alert">
		  	   <p><b>On trial</b> Email alert active</p>
		  	   <form action="" method="post" name="trial_alert"> 
	      	   </form>
	      	   </div>
	      	   <!--trial_alert-->'
		
		;} else
		
		//Has no alert set up
		{
	
		echo  '<div id="trial_alert">
		  	   <p><b>On trial</b>Set up an alert and we will email you when this saddle becomes available.</p>
		  	   <form action="http://www.24-7saddles.com/add_alertlist.php" method="post" name="trial_alert">
		 	   <input name="product_id" type="hidden" value="'.$product_row_id.'" />
		  	   <input id="alert_email" name="customer_email" type="hidden" placeholder="Enter your email address" /> 
		  	   <input id="alert_button" name="alert_button" type="submit" value="Alert" />
		   	   <a>Terms & conditions</a> 
	      	   </form>
	      	   </div>
	      	   <!--trial_alert-->'
		
		;}

	;}

}

?>  

<img src="http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_1.jpg" name="large_image" width="500" height="500" id="large_image" />

<div id="details_container"><!--Details Container-->

	<h1><?php echo $product_name ?></h1>

	<p id="product_cost"><i>Only</i>£<?php echo $product_cost ?></p>

	<p id="product_description"><?php echo $product_description ?>

	<br /><br />

	<b>Availability: </b><?php echo $product_status ?>
	
	<?php 

	if ($product_status != "On-trial") { $buy_button_type = "button";} else { $buy_button_type = "hidden";}

	?>

	<div id="button_container">

	<input 
	id="add_cart" name="add_cart" type="<?php echo $buy_button_type ?>" 
	onclick="MM_changeProp('black_out','','display','block','DIV')" 
	value="Buy now" 
	/>

	<form action="../create_product_message.php" method="post" name="product_message" id="product_message">
    
    <input name="product_id" type="hidden" value="<?php echo $product_id ?>" />
    
	<input name="product_message" type="submit" class="product_message_button" 
	id="product_message" 
	onclick="" 
	value="Ask question" 
	/>

	</form>

	</div>
 
	</p>

</div><!--END Details Container-->

<div id="small_images"><!--Small Images-->

	<h2>Product images</h2>

  <img src="http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_2.jpg" id="small_image" onmouseover="MM_swapImage('large_image','','http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_2.jpg',0)" onmouseout="MM_swapImgRestore()" />
  
  <img src="http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_3.jpg" id="small_image" onmouseover="MM_swapImage('large_image','','http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_3.jpg',0)" onmouseout="MM_swapImgRestore()" />
  
  <img src="http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_4.jpg" id="small_image" onmouseover="MM_swapImage('large_image','','http://www.24-7saddles.com/images/saddles/<?php  echo $product_row_id ?>_4.jpg',0)" onmouseout="MM_swapImgRestore()" />
  
  <p>Hover over the images to view the image.</p>
  
</div><!--End Small Images-->



<div id="additional_information">

<h2>Product information - <i>Product ID:<?php echo $product_id ?></i></h2>

<table width="960px" border="0" cellpadding="3">
	<tr>
    <td width="200px"><b>Make</b></td>
    <td><?php echo $product_make ?></td>
  </tr>
  <tr>
    <td width="200px"><b>Colour</b></td>
    <td><?php echo $product_colour ?></td>
  </tr>
  <tr>
    <td width="200px"><b>Size</b></td>
    <td><?php echo $product_size ?></td>
  </tr>
  <tr>
    <td width="200px"><b>Saddle type</b></td>
    <td><?php echo $product_sub_catagory ?></td>
  </tr>
</table>

<?php 
//print customer watch list
//TURNED OFF	print_r($alert_list); 
?>

<h2>Purchase information</h2>

<ul>
<li><b>Free trial</b><br />

This saddle qualifies for a free trial service.</li>

<li><b>Paypal checkout</b><br />

Secure online payment via paypal available for all online saddles purchased via 24-7saddles.com</li>

<li><b>Cash payment</b><br />

You can also purchase your saddle by a cash payment which is to be made on collection of your saddle.</li>

</ul>

</div>
<!--additional_information-->

</div>
<!--product_container-->

<div id="black_out">
<div id="purchase_details">


<!--<form name="purchase_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">-->

<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">

<h2 class="total_cost">Total cost <b>£<span id="total_cost_display"><?php echo $product_cost ?></span></b></h2>
<h3 class="total_cost">Saddle cost <b>£<span id="saddle_cost_display"><?php echo $product_cost ?></span></b></h3>
<h3 class="total_cost">Paypal cost <b>£<span id="paypal_cost_display">0.00</span></b></h3>
<h3 class="total_cost">Delivery cost <b>£<span id="delivery_cost_display">0.00</span></b></h3>



<div id="options_container">

<h2><b>1.</b>Delivery options</h2>

<p>Choose your delivery method below. Please note if you choose to have your saddle delivered there will be a £13 delivery cost additional to your saddle cost nad payment can only be made via paypal checkout.</p>

      <input name="delivery_options" type="radio" class="hidden" id="delivery_options_0" onclick="MM_callJS('calculate_costs ()')" value="0.00" />
      <label for="delivery_options_0" id="delivery" value="delivery">Collection + £0.00</label>


      <input name="delivery_options" type="radio" class="hidden" id="delivery_options_1" onclick="MM_callJS('calculate_costs ()')" value="13.00"  />
      <label for="delivery_options_1">Delivery + £13.00</label>
      

<h2><b>2.</b> Payment method</h2>

  <div id="cash_payment">

      <input name="payment_options" type="radio" class="hidden" id="payment_options_0" onclick="MM_callJS('calculate_costs ()')" value="Cash payment" />
      <label for="payment_options_0" class="disabled">Cash payment</label>
    </div>

      <input name="payment_options" type="radio" class="hidden" id="payment_options_1" onclick="MM_callJS('calculate_costs ()')" value="Paypal" />
      <label for="payment_options_1">Paypal</label>

</div>

      <input name="back" type="button" id="back_button" onclick="MM_changeProp('black_out','','display','none','DIV')" value="Cancel" />
      <!-- Call Javascript "product_details_payment_calcs2.js!" -->
      <input name="continue" type="button" id="continue_paypal" onclick= "MM_callJS('continue_payment ()')" value="Continue" />


<input type="hidden" id="saddle_cost" name="saddle_cost" value="<?php echo $product_cost ?>">
<input type="hidden" name="delivery_cost" value="0">
<input type="hidden" name="paypal_cost" value="0">

<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="development-facilitator@24-7saddles.com">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="item_name" value="<?php echo $product_name ?>">
<input type="hidden" name="item_number" value="<?php echo $product_id ?>">
<input type="hidden" name="amount" value="0">
<input type="hidden" name="shipping" value="0">
<input type="hidden" name="custom" value="Online_sale">

</form>

<form action="../cash_payment.php" method="post" name="cash">
<input type="hidden" name="item_name" value="<?php echo $product_name ?>">
<input type="hidden" name="item_number" value="<?php echo $product_id ?>">
<input type="hidden" name="amount" value="0">
<input type="hidden" name="shipping" value="0">
</form>

</div>
<!--Purchase details-->
</div>
<!--Black out-->

</div> 
<!--page_container-->

<?php include "footer.php" ?>

</body>
</html>